#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int max_seq(vector<int> &highs)
{
        int n = highs.size();
        vector<int> dp(n, 1);

        for(int i = 1; i < n; i++){
                for(int j = 0; j < i; j++){
                        if(highs[i] > highs[j]){
                                dp[i] = max(dp[i], dp[j] + 1);
                        }
                }
        }

        return *max_element(dp.begin(), dp.end());
}

int main()
{
        int t, n;
        cin>>t;
        while(t--){
                cin>>n;
                vector<int> highs(n);
                for(int i = 0; i < n; i++){
                        cin >> highs[i];
                }
                int up = max_seq(highs);
                reverse(highs.begin(), highs.end());
                int down = max_seq(highs);
                cout<<max(up, down)<<endl;
        }

        return 0;
}
/*
1
8
300 207 155 299 298 170 158 65
*/